import Vue from "vue";
import Vuex from "vuex";
import home from "./modules/home";
import reservation from "./modules/reservation";

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    username: null,
    uid: null,
    imgurl: null,
    phone: null,
    type: null,

    indicator: false,
    pageTransition: "fade",
  },
  mutations: {
    SET_INDICATOR(state, {
      value
    }) {
      state.indicator = value;
    },
    SET_PAGE_TRANSITION_PROP(state, {
      transitionName
    }) {
      state.pageTransition = transitionName;
    },
    SET_USER_DATA(state, preload) {
      state.username = preload.name;
      state.uid = preload.uid;
      state.phone = preload.phone;
      state.type = preload.type;
      state.imgurl = preload.imgurl;
    },
  },
  actions: {
    INIT_APP({
      commit
    }, preload) {
      commit("SET_USER_DATA", preload);
    },
  },
  modules: {
    home: home,
    reservation,
  },
});

export default store;